<?php
App::uses('AppController', 'Controller');

class InsteducativasController extends AppController {
var $name = 'Insteducativas';
	
	

      
	public function index() {
		$this->Insteducativa->recursive = 0;
		$insteducativas = $this->Insteducativa->find('all');
	$this->set('insteducativas', $this->paginate());
	

	
	
	}
		
		public function view($id = null) {
		$this->Insteducativa->id = $id;
		if (!$this->Insteducativa->exists()) {
			throw new NotFoundException(__('I.E no válido'));
		}
		$this->set('insteducativa', $this->Insteducativa->read(null, $id));
                $gestions=$this->Insteducativa->Gestion->find('list',array('fields'=>'Gestion.descripcion'));
		$this->set(compact('insteducativas','gestions'));
	}

	public function add() {
		if ($this->request->is('post')) {
			$this->Insteducativa->create();
			if ($this->Insteducativa->save($this->request->data)) {
				$this->Session->setFlash(__('el I.E ha sido guardado'));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('el I.E no puede ser guardado. Intente otra vez.'));
			}
		}
                 $gestions=$this->Insteducativa->Gestion->find('list',array('fields'=>'Gestion.descripcion'));
		$this->set(compact('insteducativas','gestions'));
	}
	
	
		public function edit($id = null) {
		$this->Insteducativa->id = $id;
		if (!$this->Insteducativa->exists()) {
			throw new NotFoundException(__('I.E Invalido'));
		}
		if ($this->request->is('post') || $this->request->is('put')) {
			if ($this->Insteducativa->save($this->request->data)) {
				$this->Session->setFlash(__('I.E ha sido guardado'));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__(' I.E no puede ser guardado. Intente otra vez.'));
			}
		} else {
			$this->request->data = $this->Insteducativa->read(null, $id);
		}
                
                $gestions=$this->Insteducativa->Gestion->find('list',array('fields'=>'Gestion.descripcion'));
		$this->set(compact('insteducativas','gestions'));
	}
	
        
        
	public function delete($id = null) {
		if (!$this->request->is('post')) {
			throw new MethodNotAllowedException();
		}
		$this->Insteducativa->id = $id;
		if (!$this->Insteducativa->exists()) {
			throw new NotFoundException(__('I.E no v�lido'));
		}
		if ($this->Insteducativa->delete()) {
			$this->Session->setFlash(__('I.E eliminado'));
			$this->redirect(array('action' => 'index'));
		}
		$this->Session->setFlash(__('la I.E no fue eliminado'));
		$this->redirect(array('action'  => 'index'));
	}
	}